<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='hblx'/></label>
                        <div class="layui-input-inline">
                            <select name="distributorScope">
                                <option value=""><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.type == 1}">selected</c:if>><fmt:message key='lx'/></option>
                                <option value="2" <c:if test="${params.type == 2}">selected</c:if>><fmt:message key='sp'/></option>
                                <option value="3" <c:if test="${params.type == 3}">selected</c:if>><fmt:message key='wd'/></option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='zt'/></label>
                        <div class="layui-input-inline">
                            <select name="distributorScope">
                                <option value=""><fmt:message key='qxz'/></option>
                                <option value="1" <c:if test="${params.status == 1}">selected</c:if>><fmt:message key='ysj'/></option>
yxj                                <option value="3" <c:if test="${params.status == 3}">selected</c:if>><fmt:message key='yxj'/></option>
                                <option value="4" <c:if test="${params.status == 4}">selected</c:if>><fmt:message key='dsh'/></option>
                                <option value="5" <c:if test="${params.status == 5}">selected</c:if>><fmt:message key='shbtg'/></option>
                            </select>
                        </div>
                    </div>

                    <input type="hidden" value="${params.platform}" name="platform">

                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> <fmt:message key='ss'/></button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <a href="javascript:void(0);" class="layui-btn layui-btn-sm" id="add"><i class="layui-icon">&#xe61f;</i> <fmt:message key='xzhb'/></a>
            <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-warm" id="enables"><i class="layui-icon">&#x1006;</i><fmt:message key='plsj'/></a>
            <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-warm" id="disables"><i class="layui-icon">&#x1006;</i><fmt:message key='plxj'/></a>
            <a href="javascript:void(0);" class="layui-btn layui-btn-sm layui-btn-danger" id="removes"><i class="layui-icon">&#x1006;</i><fmt:message key='plsc'/></a>

            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li <c:if test="${params.platform eq 1}">class="layui-this"</c:if> >
                        <a href="${web_domain}/mall/distribution/poster/list?platform=1" <c:if test="${params.platform eq 1}">style="color: rgb(0, 150, 136)"</c:if> ><fmt:message key='pthb'/></a>
                    </li>
                    <li <c:if test="${params.platform eq 2}">class="layui-this"</c:if>>
                        <a href="${web_domain}/mall/distribution/poster/list?platform=2" <c:if test="${params.platform eq 2}">style="color: rgb(0, 150, 136)"</c:if>><fmt:message key='sjhb'/></a>
                    </li>
                </ul>
            </div>

            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <th width="5%"><input id="checkboxs" type="checkbox" lay-ignore lay-skin="primary"/></th>
                    <th><fmt:message key='xh'/></th>
                    <th><fmt:message key='nr'/></th>
                    <th><fmt:message key='sm'/></th>
                    <th><fmt:message key='lx'/></th>
                    <th><fmt:message key='cjsj'/></th>
                    <th><fmt:message key='zt'/></th>
                    <th><fmt:message key='cz'/></th>
                </tr>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td><input type="checkbox" value="${item.id}" class="feijin-check" lay-ignore lay-skin="primary"/></td>
                        <td>${status.index + 1}</td>
                        <td><img style="width:40px; height:40px;" class="preview" src="${store_domain}/uploads/${item.image}"/></td>
                        <td>${item.content}</td>
                        <td>
                            <c:if test="${item.type == 1}"><fmt:message key='lx'/></c:if>
                            <c:if test="${item.type == 2}"><fmt:message key='sp'/></c:if>
                            <c:if test="${item.type == 3}"><fmt:message key='wd'/></c:if>
                        </td>
                        <td><fmt:formatDate value="${item.createTime}" type="both"/></td>
                        <td>
                            <c:if test="${item.status == 1}"><fmt:message key='ysj'/></c:if>
                            <c:if test="${item.status == 2}"><fmt:message key='yxj'/></c:if>
                            <c:if test="${item.status == 3}"><fmt:message key='dtj'/></c:if>
                            <c:if test="${item.status == 4}"><fmt:message key='dsh'/></c:if>
                                <c:if test="${item.status == 5}"><fmt:message key='shbtg'/></c:if>
                        </td>
                        <td>
                            <div class="layui-btn-container">
                                <c:if test="${item.status == 1}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-warm layui-btn-xs disable"><fmt:message key='xj'/></a>
                                </c:if>

                                <c:if test="${item.status == 2}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs enable"><fmt:message key='sj'/></a>
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs remove"><fmt:message key='sc'/></a>
                                </c:if>

                                <c:if test="${item.status == 3}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs modify"><fmt:message key='bj'/></a>
                                </c:if>

                                <c:if test="${item.status == 5}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs modify"><fmt:message key='bj'/></a>
                                </c:if>

                                <c:if test="${item.status == 4}">
                                    <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs check"><fmt:message key='sh'/></a>
                                </c:if>

                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='xq'/></a>

                            </div>
                        </td>

                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>

    layui.use(['form', 'layer'], function () {

        var layer = layui.layer;
        var form = layui.form;

        //全选反选
        $("#checkboxs").click(function () {
            if (this.checked) {
                $(".feijin-check:checkbox").prop("checked", true);
            } else {
                $(".feijin-check:checkbox").prop("checked", false);
            }
        });

        //添加海报
        $("#add").click(function () {
            layer.open({
                type: 2
                , title: '<fmt:message key='tjhb'/>'
                , content: '${web_domain}/mall/distribution/poster/create'
                , maxmin: true
                , area: ['92%', '92%']
                , btn: ['<fmt:message key='bc'/>', '<fmt:message key='qx'/>']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

        //查看
        $(".feijin-detail").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2
                , title: '<fmt:message key='ckfxhb'/>'
                , content: '${web_domain}/mall/distribution/poster/detail?id=' + id
                , maxmin: true
                , area: ['90%', '90%']
                , btn: ['<fmt:message key='fh'/>']
            });
        });

        //编辑海报
        $(".modify").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2
                , title: '<fmt:message key='bjhb'/>'
                , content: '${web_domain}/mall/distribution/poster/'+ id +'/modify'
                , maxmin: true
                , area: ['92%', '92%']
                , btn: ['<fmt:message key='bc'/>', '<fmt:message key='qx'/>']
                , yes: function (index, layero) {
                    var submit = layero.find('iframe').contents().find("#submit");
                    submit.click();
                }
            });
        });

        //审核
        $(".check").click(function () {
            var id = $(this).attr("data-id");
            layer.open({
                type: 2,
                content: "${web_domain}/mall/distribution/poster/"+ id +"/check",
                area: ["60%", "60%"],
                btn: ["<fmt:message key='qd'/>", "<fmt:message key='qx'/>"],
                yes: function (index, layero) {
                    layero.find('iframe').contents().find("#submit").click();
                }
            });
        });

        //上架
        $(".enable").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrsjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/distribution/poster/enable",
                    data: {"id": id}
                });
            });
        });

        //下架
        $(".disable").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrxjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/distribution/poster/disable",
                    data: {"id": id}
                });
            });
        });


        //移除
        $(".remove").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrycghbm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/distribution/poster/remove",
                    data: {"id": id}
                });
            });
        });

        //批量移除
        $("#removes").click(function () {
            var ids = [];
            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });
            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }
            layer.confirm("<fmt:message key='qryjxzdfxhbycm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/distribution/poster/removes",
                    data: {"ids": ids.join(";")}
                });
            });
        });

        //批量上架
        $("#enables").click(function () {
            var ids = [];
            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });
            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }
            layer.confirm("<fmt:message key='qryjxzdfxhbtsjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/distribution/poster/enables",
                    data: {"ids": ids.join(";")}
                });
            });
        });

        //批量下架
        $("#disables").click(function () {
            var ids = [];
            $(".feijin-check:checkbox:checked").each(function (index, item) {
                var id = $(item).val();
                ids.push(id);
            });
            if (ids.length === 0) {
                layer.msg('<fmt:message key='qxgxxyczdjl'/>');
                return false;
            }
            layer.confirm("<fmt:message key='qryjxzdfxhbtxjm?'/>", function () {
                feijin.put({
                    url: "${web_domain}/mall/distribution/poster/disables",
                    data: {"ids": ids.join(";")}
                });
            });
        });

    });

</script>
</body>
</fmt:bundle>
</html>
